package com.imstlife.vending.push2.push;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;


import com.imstlife.vending.sgy.logger.LocalLog;

import org.json.JSONException;
import org.json.JSONObject;


@SuppressLint("ShowToast")
public class MessageHandler {
    public static final String TAG = "MessageHandler";
    String updatalog = "";
    String pushQr = "";

    /**
     * 统一处理个推和极光消息
     * {"action":"unLock","timestamp":1602215346304,"data":{"unLockWay":2,"expireTime":""}}
     */
    public void pushMessage(Context context, String data, int type) {
        LocalLog.e("pushMessage", data+"");
        try {
            JSONObject jobj = new JSONObject(data);

            if (jobj.getString("actionName") != null && jobj.getString("actionName").equals("uploadLogDetail")){
                if(updatalog.equals(jobj.getString("hashValue"))){

                }else{
                    updatalog = jobj.getString("hashValue");
                    Intent intent = new Intent("ACTION_UPLOADLOG_NEW");
                    intent.putExtra("data", data);
                    context.sendBroadcast(intent);
                }

            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
